package cn.tedu.util;

import javax.swing.*;
import java.security.Key;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

//测试 HashMap实现类
public class Test5_2 {
    public static void main(String[] args) {
        HashMap<Integer,String> map=new HashMap<>();

        map.put(999,"杨幂");
        map.put(888,"赵敏");
        map.put(666,"周雨");
        map.put(555,"流星");
        map.put(333,"小雪");
        map.put(222,"阿悠悠");
        System.out.println(map);
        System.out.println(map.containsKey(222));
        System.out.println(map.containsValue("流星"));
        System.out.println(map.equals(888));
        System.out.println(map.get(888));
        System.out.println(map.size());
        System.out.println(map.isEmpty());
        System.out.println(map.remove(555));

        Set<Integer> keys=map.keySet();
        for (Integer k:keys) {
            String v=map.get(k);
            if (v.equals("流星")){
                System.out.println(v+",加个微信呗！");
            }
            System.out.println(k+""+v);
        }
        Set<Map.Entry<Integer,String>> entrys=map.entrySet();
        for (Map.Entry<Integer,String> entry:entrys) {
            Integer k=entry.getKey();
            String v=entry.getValue();
            System.out.println(k+v );
        }
    }
}
